package com.mmall.concurrent.example.threadPool;/**
 * Created with IDEA
 * Author : wangfei
 * Date :  2019/10/22
 * Time : 15:54
 * Describe :
 */

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName TreadPoolExample1
 * @Describe :
 * @Author : wangfei 
 * @Date :  2019/10/22 15:54
 */
@Slf4j
public class TreadPoolExample4 {
	public static void main(String[] args) {
		ScheduledExecutorService executorService = Executors.newScheduledThreadPool(5);
//		for (int i = 0; i < 10; i++) {
//			final int index = i;
//			executorService.execute(new Runnable() {
//				@Override
//				public void run() {
//					log.info("task: {}", index);
//				}
//			});
//
//		}

		executorService.scheduleAtFixedRate(new Runnable() {
			@Override
			public void run() {
				long time = System.currentTimeMillis();
				log.info("schedule run time :{}", time);
			}
		}, 1, 3, TimeUnit.SECONDS);

//		executorService.shutdown();

	}
}
